function fillFormWithJson(form,json){
	
	var elements = form.elements;
	
	try{
		for (var i = 0; i < elements.length; i++) {
			var e = elements[i];
			var value = json[e.name];
			if(e.name == null || e.name == undefined){
				continue;
			}
			if(value == null || value == undefined){
				continue;
			}
			if(e.type == "text" || e.type == "hidden" || e.type == "textarea"){
				e.value = value;
			}else if(e.type == "select"){
				//var elementId = $(e).attr("id");
				//if(elementId != undefined){
				//	ViewLoader.selects[elementId]
				//}
			}
			if($(e).attr("treeid") != undefined){
				var treeid = $(e).attr("treeid");
				$.jstree.reference("#"+treeid).deselect_all(true);
				$.jstree.reference("#"+treeid).select_node(treeid+"_"+value);
			}
		}
	}catch(e){
		alert(e.message);
	}
}
function queryGrid(form,id,target){
	var grid = ViewLoader.grids[target];
	try{
		grid.query(id,getQueryString(form));
	}catch(e){
		alert(e.message);
	}
}
function getQueryString(form){
	var queryString = "";
	var elements = form.elements;
	for (var i = 0; i < elements.length; i++) {
		var e = elements[i];
		if(e.name == null || e.name == undefined){
			continue;
		}
		if(e.value == null || e.value == ""){
			continue;
		}
		if(queryString != "")
			queryString += "&";
		queryString += (e.name + "="+ e.value);
	}
	return queryString;
}
function getJsonFromForm(form){
	
	return form.serialize();
}
function ajaxPost(url,data,callback,cache,async){
	ajaxRequest(url, data, "POST", callback, cache, async);
}
function ajaxGet(url,data,callback,cache,async){
	ajaxRequest(url, data, "GET", callback, cache, async);
}
function ajaxRequest(url,data,method,callback,cache,async){
	if(cache == undefined){
		cache = true;
	}
	if(async == undefined){
		async = true;
	}
	$.ajax({
		type: method,
		url: url,
		cache:cache,
		async:async,
		data:data,
		dataType: "json",
		success: callback,
		error:function(result){
			alert("系统错误！");
			//window.location.href=basePath + "/error";
		}
	});
}

function defaultDateRender(data, type, full){
	if(data == undefined || data == null)
		return "";
	else{
		return data.split(" ")[0];
	}
}
function addUrlParams(url,param){
	if(url.indexOf("?") > 0){
		return url + "&" + param;
	}else{
		return url + "?" + param;
	}
}
function isBlank(obj){
	return obj == null || obj == "";
}